package br.ucb.cm.main.mainview.ui;

import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.ImageIcon;
import java.awt.Dimension;
import java.awt.BorderLayout;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.border.BevelBorder;
import java.awt.Font;
import javax.swing.SwingConstants;
import javax.swing.border.EtchedBorder;

public class PointPanel extends JPanel {
	private static final long serialVersionUID = 1L;
	private JLabel playerPoints;
	private JLabel computerPoints;

	public PointPanel() {
		initComponents();
	}
	
	public void setPoints(Integer player, Integer computer){
		playerPoints.setText(player.toString());
		computerPoints.setText(computer.toString());
	}
	
	private void initComponents() {
		JPanel panelPlayer = new JPanel();
		panelPlayer.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
		panelPlayer.setLayout(new BorderLayout(0, 0));
		
		JLabel lblPlayer = new JLabel("");
		lblPlayer.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
		lblPlayer.setIcon(new ImageIcon(PointPanel.class.getResource("/br/ucb/cm/main/mainview/resources/user_male_olive_green.png")));
		lblPlayer.setPreferredSize(new Dimension(48, 48));
		lblPlayer.setMinimumSize(new Dimension(48, 48));
		lblPlayer.setMaximumSize(new Dimension(48, 48));
		panelPlayer.add(lblPlayer, BorderLayout.WEST);
		
		playerPoints = new JLabel("0");
		playerPoints.setHorizontalAlignment(SwingConstants.CENTER);
		playerPoints.setFont(new Font("DialogInput", Font.BOLD, 35));
		panelPlayer.add(playerPoints, BorderLayout.CENTER);
		
		JPanel panelComputer = new JPanel();
		panelComputer.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
		panelComputer.setLayout(new BorderLayout(0, 0));
		
		JLabel lblComputer = new JLabel("");
		lblComputer.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
		lblComputer.setIcon(new ImageIcon(PointPanel.class.getResource("/br/ucb/cm/main/mainview/resources/my_computer.png")));
		lblComputer.setPreferredSize(new Dimension(48, 48));
		lblComputer.setMinimumSize(new Dimension(48, 48));
		lblComputer.setMaximumSize(new Dimension(48, 48));
		panelComputer.add(lblComputer, BorderLayout.WEST);
		
		computerPoints = new JLabel("0");
		computerPoints.setHorizontalAlignment(SwingConstants.CENTER);
		computerPoints.setFont(new Font("DialogInput", Font.BOLD, 35));
		panelComputer.add(computerPoints, BorderLayout.CENTER);
		GroupLayout groupLayout = new GroupLayout(this);
		groupLayout.setHorizontalGroup(
			groupLayout.createParallelGroup(Alignment.LEADING)
				.addComponent(panelPlayer, GroupLayout.DEFAULT_SIZE, 548, Short.MAX_VALUE)
				.addComponent(panelComputer, GroupLayout.DEFAULT_SIZE, 548, Short.MAX_VALUE)
		);
		groupLayout.setVerticalGroup(
			groupLayout.createParallelGroup(Alignment.LEADING)
				.addGroup(groupLayout.createSequentialGroup()
					.addComponent(panelPlayer, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
					.addGap(1)
					.addComponent(panelComputer, GroupLayout.PREFERRED_SIZE, 48, GroupLayout.PREFERRED_SIZE))
		);
		setLayout(groupLayout);
	}
}
